home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
DirectoryDialog.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-06-02
|
3KB
|
121 lines
#ifdef __GNUG__
#pragma implementation
#endif
#include "DirectoryDialog.h"
#include "Class.h"
#include "PopupItem.h"
#include "ImageItem.h"
#include "BorderItems.h"
#include "Expander.h"
#include "Buttons.h"
#include "CheapText.h"
#include "CollView.h"
#include "OrdColl.h"
#include "Directory.h"
#include "Data.h"
#include "Fields.h"
#include "Form.h"
#include "Menu.h"
#include "Scroller.h"
#include "System.h"
const int cIdDirOpen = cIdFirstUser + 130;
//---- DirectoryDialog ---------------------------------------------------------
NewMetaImpl0(DirectoryDialog,FileDialog);
DirectoryDialog *DirectoryDialog::gDirectoryDialog;
char *DirectoryDialog::GetDirectory(Window *w, EvtHandler *eh)
{
if (gDirectoryDialog == 0)
gDirectoryDialog= new DirectoryDialog;
if (gDirectoryDialog->ShowInWindow(eFDRead, w, eh, "Directory Name") == cIdOk)
return gSystem->WorkingDirectory();
return 0;
}
ONEXIT(DirectoryDialog)
{
SafeDelete(DirectoryDialog::gDirectoryDialog);
}
DirectoryDialog::DirectoryDialog() : FileDialog("Directory Dialog")
{
}
VObject *DirectoryDialog::MakeFileItem(Data *data)
{
FileItem *fi= new FileItem(data);
fi->Enable(data->IsDirectory(), FALSE);
return fi;
}
VObject *DirectoryDialog::DoMakeContent()
{
pathPopup= new PopupButton(cIdPath, cIdNone,
new Menu("Current Directory", FALSE, FALSE));
collview= new CollectionView(this, new OrdCollection, eCVDontStuckToBorder);
collview->SetMinExtent(Point(cItemMinWidth, 0));
collview->SetId(cIdList);
return
new Matte(
new VExpander(20,
new Form(cIdNone, (VObjAlign)(eVObjVBase+eVObjHExpand), gPoint10,
"Current Directory:", pathPopup,
0
),
scroller= new Scroller(collview, Point(cItemMinWidth, ItemHeight()*cNumItems), cIdList),
new VExpander(gPoint2,
title,
eti= new TextField(cIdName, 20),
0
),
new HBox(20, (VObjAlign)(eVObjVBase|eVObjHEqual|eVObjHExpand),
selectButton= new ActionButton(cIdDirOpen, "Select", TRUE),
openButton= new ActionButton(cIdOk, "Open"),
new ActionButton(cIdCancel, "Cancel"),
new ActionButton(cIdUpdate, "Update"),
0
),
0
)
);
}
void DirectoryDialog::DoSetup()
{
bool e= FALSE;
if (eti->GetTextSize() > 0) {
char pathname[cPathBuf];
eti->GetString(pathname, cPathBuf);
if (gSystem->ExpandPathName(pathname, cPathBuf-1))
return;
FileData *fd= new FileData(pathname);
e= fd->IsDirectory();
delete fd;
}
openButton->Enable(e);
selectButton->Enable(e);
}
void DirectoryDialog::Control(int id, int p, void *v)
{
switch (id) {
case cIdDirOpen:
OpenOrChangeDir();
Dialog::Control(cIdOk, p, v);
return;
}
FileDialog::Control(id, p, v);
}